import json
import glob

# 读取原始 processed_records.json 文件
with open('processed_records.json', 'r') as f:
    existing_records = json.load(f)

# 创建一个集合以存储唯一的记录
unique_records = set(existing_records)

# 遍历所有的 processed_records_thread_*.json 文件
for filename in glob.glob('processed_records_thread_*.json'):
    with open(filename, 'r') as f:
        thread_records = json.load(f)
        unique_records.update(thread_records)  # 添加新记录

# 将合并后的记录写入 processed_records.json
with open('processed_records.json', 'w') as f:
    json.dump(sorted(unique_records), f)  # 排序并写入
